#include <iostream>
#include <map>
#include <vector>

int main() {
    int n, k, s;

    std::cin >> n >> k >> s;

    std::map<int, std::vector<int>> with_GPLT_score;

    for (int i = 0; i < n; ++i) {
        int GPLT_score, PTA_score;
        std::cin >> GPLT_score >> PTA_score;

        if (GPLT_score < 175) { continue; }

        auto it = with_GPLT_score.find(GPLT_score);
        if (it == with_GPLT_score.end()) {
            with_GPLT_score[GPLT_score] = std::vector<int>();
        }

        with_GPLT_score[GPLT_score].push_back(PTA_score);
    }
    
    int tot = 0;

    // 第一批

    for (auto & pair : with_GPLT_score) {
        auto GPLT_score = pair.first;
        
        int cnt = 0;

        auto it = with_GPLT_score[GPLT_score].begin();
        while (it != with_GPLT_score[GPLT_score].end()) {
            if ((*it) >= s) {
                cnt += 1;
                it = with_GPLT_score[GPLT_score].erase(it);
            } else {
                ++it;
            }
        }

        if (with_GPLT_score[GPLT_score].size() > 0) {
            cnt += 1;
            with_GPLT_score[GPLT_score].pop_back();
        }

        tot += cnt;
    }

    // 剩余批

    for (int i = 1; i < k; ++i) {
        for (auto & pair : with_GPLT_score) {
            auto GPLT_score = pair.first;

            int cnt = 0;

            if (with_GPLT_score[GPLT_score].size() > 0) {
                cnt += 1;
                with_GPLT_score[GPLT_score].pop_back();
            }

            tot += cnt;
        }
    }

    std::cout << tot;
}
